Skip to content

SDK 0.3.0: drums mcp server and CLI, HTTPS-only token transport - #7

Merged
sahiljagtap08 merged 5 commits into
mainfrom
mcp-server-r2
Nov 12, 2026
Merged

sahiljagtap08 merged 5 commits into
mainfrom
mcp-server-r2

Conversation

@sahiljagtap08

@sahiljagtap08 sahiljagtap08 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Re-land of #3 (merged as 4cd3850, reverted as ee24be6) with the reviewer's conditions. Not published to PyPI; no tag. Version stays 0.3.0.

Contents

  • c08c689 revert of the revert: the 0.3.0 content of drums mcp: two-layer MCP stdio server, drums CLI, Claude Code plugin #3 comes back as-is (drums mcp stdio server with the 34 tools of drums/mcp_tools.json, the drums console script, --print-config claude|claude-local|cursor|codex, Client.runs/create_run/run/api_keys/create_api_key/revoke_api_key/audit, the Claude Code plugin and drums-workflow skill).
  • d3ad482 transport rule (new in this round, see below).
  • 52ca831 tests for the rule and for --print-config never printing a token.
  • 479bf53 README, skill and CHANGELOG wording.
  • d0626ca redirect rule (reviewer finding on the first round, see below).

Token transport rule

A token is sent over https, or over plain http to loopback only (localhost, 127.0.0.0/8, ::1). With a token set, any other http:// URL from --url, DRUMS_URL, DRUMS_TOKEN_FILE or /etc/drums/token is refused before any request:

  • drums.Client / drums.connect raise the new drums.InsecureTransport (a DrumsError), so SDK scripts are covered, not just the CLI;
  • drums mcp prints one line to stderr naming the host and the opt-ins and exits 2.

The message never contains the token. Opt-ins: drums mcp --allow-insecure-http, DRUMS_ALLOW_INSECURE_HTTP=1, Client(..., allow_insecure_http=True) / connect(..., allow_insecure_http=True). drums.check_transport(url, token, allow_insecure_http=None) is the check itself. --print-config is unaffected (it prints placeholders and sends nothing).

Redirect rule

urllib's default handler follows any 30x and re-sends Authorization, which would carry the token past the transport check. Client.call now opens requests through an opener whose HTTPRedirectHandler follows a redirect only to the same origin (scheme, host, port) as the request, at most drums.MAX_REDIRECTS (5) hops, and runs check_transport on each hop; a redirect to another host or port, https to http, or a sixth hop raises the new drums.RedirectRefused before it is followed. Its message names the target's scheme, host and port only (no token, userinfo, path or query). 308 is handled like 307 on Pythons before 3.11. drums.aio wraps the sync Client in an executor, so it goes through the same opener.

confirm: true wording

README, the skill and the CHANGELOG now say: destroy_computer, delete_snapshot and revoke_api_key are refused before any request unless the tool arguments carry confirm: true; the caller (the agent) supplies that argument, Drums does not prompt anyone, and approval of the call belongs to the MCP client (Claude Code, Cursor, Codex) and its tool-approval settings. There is no confirmation step inside Drums. reset is noted as discarding desktop state but is not gated (unchanged from #3; mcp_tools.json mirrors the gateway's list).

Tests

python -m unittest discover -s tests: 76 tests, OK on Python 3.12.5 and 3.9.6 (the 53 of #3 plus 23 new: tests/test_transport.py, and additions to tests/test_cli.py and tests/test_mcp_server.py). They cover: off-loopback http refused with a token (Client, connect, CLI --url, DRUMS_URL, token file); http://localhost:7070, http://127.0.0.1, http://[::1] and https allowed; the flag, env var and kwarg opt-ins; no token in any refusal or exception text; all four --print-config formats with the token in DRUMS_TOKEN and in DRUMS_API_KEY never printing it; initialize and tools/list sending nothing to the gateway; redirects against a loopback server: cross-host, cross-port (a second loopback listener sees no connection), https-origin to http (the handler called as urllib calls it, with an https request URL), same-origin followed with Authorization on the second request, loop and chain capped at 5, no token/userinfo/query in RedirectRefused.

… other http URLs are refused unless --allow-insecure-http / DRUMS_ALLOW_INSECURE_HTTP=1 / allow_insecure_http=True

Client and connect() run check_transport before any request: with a token, an http (not https) URL whose host is not localhost, 127.0.0.0/8 or ::1 raises InsecureTransport. The CLI (drums mcp) maps that to a one-line stderr message and exit 2. The message names the host and the opt-ins, never the token.
…loopback and https allowed, the three opt-ins, no token in any message), --print-config never prints DRUMS_TOKEN or DRUMS_API_KEY, tools/list sends nothing
…oval; the HTTPS-only token rule and its opt-ins (README, skill, CHANGELOG 0.3.0)
…hops, with check_transport on every hop; any other redirect raises RedirectRefused unfollowed

urllib's default redirect handler follows a 30x anywhere and re-sends every header, Authorization included, which would carry the token past check_transport to another host or to plain http. Client.call now opens requests through an opener whose HTTPRedirectHandler compares the hop target's (scheme, host, port) with the request's, refuses a different origin or a sixth hop with RedirectRefused (message: scheme, host and port of the target only), and runs check_transport on same-origin hops. 308 is handled like 307 on Pythons before 3.11. aio goes through Client.call and needs nothing of its own.
@sahiljagtap08
sahiljagtap08 merged commit 42edffe into main Nov 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant